package com.heima.redis;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class RecentCounter {
    private Queue<Integer> queue;

    public RecentCounter() {
        queue=new LinkedList<>();
    }

    public int ping(int t) {
        queue.offer(t);
        while (queue.peek()>t-3000){
            queue.poll();
        }
        return queue.size();
       /* int index=0;
        list.add(t);
        min=t-3000;
        max=t;
        for (int i = 0; i < list.size(); i++) {
            if ((list.get(i)<=max) &&(list.get(i)>=min)){
                index++;
            }
        }
        return index;*/
    }

}
